home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lantools / blueprnt / bpserial.asm < prev    next >
Assembly Source File  |  1990-01-30  |  5KB  |  171 lines

  1. ;************************************************************
  2. ;* BP-LAN Physical Layer for Serial I/O      (BPSERIAL.ASM) *
  3. ;* by Craig Chaiken                                         *
  4. ;* January 30, 1990                                         *
  5. ;*                                                          *
  6. ;* Function:                                                *
  7. ;*     Directly Controls Physical I/O on One Serial Port    *
  8. ;* Command Format:                                          *
  9. ;*     BPSERIAL /io_base_addr /config_byte /baud_rate_word  *
  10. ;************************************************************
  11. ;
  12.         include bpbioshd.mod
  13. codeseg segment
  14.         assume  cs:codeseg,ds:codeseg
  15.         org     100h
  16. start:  jmp     install
  17. in_stat dd    0
  18. out_stat    dd    0
  19.  
  20. ;*** Byte Input/Output Drivers ***
  21. ;
  22. in_byte proc    near            ;*** Receive Byte from Current Node ***
  23.         push    dx
  24.         push    ax
  25.     mov    dx,cs:curport
  26.         add     dx,5
  27. getby1: in      al,dx
  28.         test    al,1
  29.     jz    getby1
  30.     pop    ax
  31.     mov    dx,cs:curport
  32.         in      al,dx
  33.     pop    dx
  34.         bpbios  link_int,calc_checksum
  35.         retf
  36. in_byte endp
  37.  
  38. out_byte proc    near             ;*** Transmit Byte to Current Node ***
  39.     push    ax
  40. putby1: call    cs:out_stat
  41.         jz      putby1
  42.     call    outport
  43.     pop    ax
  44.         bpbios  link_int,calc_checksum
  45.         retf
  46. out_byte endp
  47.  
  48. ;*** Hardware Level Input/Output Drivers ***
  49. ;
  50. inport  proc    near            ;*** Read Current Node's Data Port ***
  51.         push    dx
  52.         mov     dx,cs:curport
  53.         in      al,dx
  54.         pop     dx
  55.         ret
  56. inport  endp
  57.  
  58. outport proc    near            ;*** Write to Current Node's Data Port ***
  59.         push    dx
  60.         mov     dx,cs:curport
  61.         out     dx,al
  62.         pop     dx
  63.         ret
  64. outport endp
  65.  
  66. in_status       proc    near    ;*** Return NZ if Data in Receive Buffer ***
  67.         push    ax
  68.         push    dx
  69.         mov     dx,cs:curport
  70.         add     dx,5
  71.         in      al,dx
  72.         test    al,1
  73.         pop     dx
  74.         pop     ax
  75.         retf
  76. in_status       endp
  77.  
  78. out_status      proc    near    ;*** Return NZ if Transmit Buffer is Empty ***
  79.         push    ax
  80.         push    dx
  81.         mov     dx,cs:curport
  82.         add     dx,5
  83.         in      al,dx
  84.         test    al,40h
  85.         pop     dx
  86.         pop     ax
  87.         retf
  88. out_status      endp
  89.  
  90. curport dw      03f8h
  91. conf    dw      3
  92. brw     dw      1
  93.  
  94. ;*** End of Resident Code ***
  95.  
  96. setbaud proc    near            ;*** Set Baud Rate as Determined by BRW ***
  97.         push    cx
  98.         push    dx
  99.         mov     dx,curport      ;Divisor Latch = 1
  100.         add     dx,3
  101.         mov     al,80h
  102.         out     dx,al
  103.     dec    dx        ;Disable Interrupts
  104.     mov    al,0
  105.     out    dx,al
  106.  
  107.         mov     cx,brw          ;Output Baud Rate Word
  108.         mov     dx,curport
  109.         mov     al,cl
  110.         out     dx,al
  111.         mov     al,ch
  112.         inc     dx
  113.         out     dx,al
  114.  
  115.         inc     dx              ;Configure UART
  116.         inc     dx
  117.         mov     ax,conf
  118.         out     dx,al
  119.         pop     dx
  120.         pop     cx
  121.  
  122.     push    ax        ;Setup Table for Faster Access to Status
  123.         mov     ax,offset in_status
  124.         mov     word ptr cs:in_stat,ax
  125.         pop     ax
  126.         mov     word ptr cs:in_stat+2,cs
  127.     push    ax
  128.         mov     ax,offset out_status
  129.         mov     word ptr cs:out_stat,ax
  130.         pop     ax
  131.         mov     word ptr cs:out_stat+2,cs
  132.         ret
  133. setbaud endp
  134.  
  135.         include misc.mod
  136.  
  137. install proc    near
  138.         mov     al,cs:[80h]     ;use default options if command line empty
  139.         or      al,al
  140.         jz      default
  141.         mov     si,81h
  142.         call    get_opt ;get serial I/O base port
  143.         jb      default
  144.         mov     cs:curport,cx
  145.         call    get_opt ;get serial configuration byte
  146.         jb      default
  147.         mov     cs:conf,cx
  148.         call    get_opt ;get baud rate word
  149.         jb      default
  150.         mov     cs:brw,cx
  151. default:
  152.         call    setbaud
  153.         mov     al,receive_status
  154.         bpbios  ctrl_int,install_port,,,offset in_status
  155.         mov     al,transmit_status
  156.         bpbios  ctrl_int,install_port,,,offset out_status
  157.         mov     al,receive_byte
  158.         bpbios  ctrl_int,install_port,,,offset in_byte
  159.         mov     al,transmit_byte
  160.         bpbios  ctrl_int,install_port,,,offset out_byte
  161.         bpbios  ctrl_int,next_port
  162.         mov     dx,offset setbaud
  163.         int     27h
  164. install endp
  165.  
  166. codeseg ends
  167.         end     start
  168. ;************************************************************
  169. ;* End of BPSERIAL.ASM                                      *
  170. ;************************************************************
  171.